//
//  LoginPrompt.m
//  iHealthEHR
//
//  Created by Joseph Ayo Akinyele on 4/10/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "LoginPrompt.h"


@implementation LoginPrompt
@synthesize username, password, profile;

- (id)initWithTitle:(NSString *)title message:(NSString *)message 
delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle 
okButtonTitle:(NSString *)okayButtonTitle
{
    if (self = [super initWithTitle:title message:@"\n\n\n\n\n" delegate:delegate 
				  cancelButtonTitle:cancelButtonTitle otherButtonTitles:okayButtonTitle, nil])
    {
		/* username textfield */
        UITextField *theUsername = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 250.0, 25.0)]; 
        [theUsername setBackgroundColor:[UIColor whiteColor]]; 
		[theUsername setPlaceholder:@"Enter email"];
		/* password textfeild */
		UITextField *thePassword = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 85.0, 250.0, 25.0)];
		[thePassword setBackgroundColor:[UIColor whiteColor]];
		[thePassword setPlaceholder:@"Enter password"];
		thePassword.secureTextEntry = YES;
		/* profile name text field */
        UITextField *theProfile = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 120.0, 250.0, 25.0)]; 
        [theProfile setBackgroundColor:[UIColor whiteColor]]; 
		[theProfile setPlaceholder:@"Profile name"];	
		
        [self addSubview:theUsername];
		[self addSubview:thePassword];
		[self addSubview:theProfile];
        self.username = theUsername;
		self.password = thePassword;
		self.profile = theProfile;
        [theUsername release];
		[thePassword release];
		[theProfile release];
		/* reposition where the alert is displayed -- move higher on the screen */
        CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 110.0); 
        [self setTransform:translate];
    }
    return self;
}

-(void) show
{
	[username becomeFirstResponder];
	[password becomeFirstResponder];
	[profile becomeFirstResponder];
	[super show];
}

- (void)dealloc {
	[username release];
	[password release];
    [super dealloc];
}


@end
